#include "queue.h"


//入队操作
void enqueue(queue_t *queue, int netFD){
    //创建一个节点
    qnode_t *node = (qnode_t *)malloc(1*sizeof(qnode_t));
    node->netFD = netFD;
    node->next = NULL;
    //头指针为空
    if(queue->head == NULL){
        queue->head = node;
        queue->tail = node;
    }else{
        //头指针不为空
        queue->tail->next = node;
        queue->tail = node;
    }
    (queue->queue_size)++;
}


//出队操作
void dequeue(queue_t *queue){
    //队列中无节点
    if(queue->queue_size <= 0){
        return;
    }

    qnode_t *curr = queue->head;
    if(queue->queue_size == 1){
    //队列中一个节点
        queue->head = NULL;
        queue->tail = NULL;
    }else{
        //队列中多个节点
        queue->head = queue->head->next;
    }
    (queue->queue_size)--;
    free(curr);

}
